package com.goodflower.goodflower.user_register;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.goodflower.goodflower.R;

public class User_register_password extends AppCompatActivity {
    private EditText register_password;//密码
    private EditText register_phone;//手机号
    private Button register_password_next;//下一步按钮
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_register_password);
        //找到控件
        register_password = (EditText)findViewById(R.id.register_password);
        register_phone = (EditText)findViewById(R.id.register_phone);
        register_password_next = (Button)findViewById(R.id.register_password_next);
        //获取info activity的数据
        Intent from_register_info_intent = getIntent();
        final String name = from_register_info_intent.getStringExtra("name");
        //下一步按钮点击事件
        register_password_next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取用户输入的密码和手机号
                String password = register_password.getText().toString();
                String phone = register_phone.getText().toString();
                StringBuilder warn_sb = new StringBuilder();
                if(password==null||password.isEmpty()){
                    warn_sb.append("密码不可以为空\n");
                }
                if(phone==null||phone.isEmpty()){
                    warn_sb.append("手机号不可以为空");
                }
                String tishi = warn_sb.toString(); //构建警告语句
                if(tishi==null||tishi.isEmpty()){
                    Intent register_password_intent = new Intent(User_register_password.this, User_register_image.class);
                    register_password_intent.putExtra("name",name);
                    register_password_intent.putExtra("password",password);
                    register_password_intent.putExtra("phone",phone);
                    startActivity(register_password_intent);
                }else {
                    Toast.makeText(User_register_password.this,tishi,Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
